package redpacket.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import redpacket.model.RedPacketRecord;

import java.util.List;

@Mapper
public interface RedPacketRecordMapper {

    @Insert("INSERT INTO red_packet_record(packet_id, user_id, amount, create_time) " +
            "VALUES(#{packetId}, #{userId}, #{amount}, #{createTime})")
    int insert(RedPacketRecord r);

    @Select("SELECT * FROM red_packet_record WHERE packet_id = #{packetId} ORDER BY id ASC")
    List<RedPacketRecord> listByPacketId(@Param("packetId") Long packetId);
}
